home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
sound
/
players
/
resound.arc
/
RESOUND.S
< prev
next >
Wrap
Text File
|
1989-09-22
|
16KB
|
460 lines
* PLAY DIGITIZED SOUND FILE WHEN TERMINATING PROGRAM
move.l 4(a7),a0 calculate program size
move.l #$100,d6
add.l 12(a0),d6
add.l 20(a0),d6
add.l 28(a0),d6
clr.l -(a7) enter supervisor mode
move.w #$20,-(a7)
trap #1
addq.l #6,a7
move.l d0,d4 save ssp
pea dta(PC) set DTA
move.w #$1A,-(a7)
trap #1
addq.l #6,a7
move.w #0,-(a7) look for RESOUND.INF
pea inf_file(PC)
move.w #$4E,-(a7)
trap #1
add.l #8,a7
lea no_inf(PC),a1
tst d0
bne problem
lea dta(PC),a6
move.l 26(a6),d7 get RESOUND.INF file length
sub.l #1,d7
andi.l #$F,d7
clr.w -(a7) open RESOUND.INF
pea inf_file(PC)
move.w #$3D,-(a7)
trap #1
add.l #8,a7
lea open(PC),a1
tst.l d0
bmi problem
move.w d0,d5 save file handle
pea freq_ind(PC) pointer to buffer
move.l d7,-(a7) number of bytes to read
move.w d5,-(a7) file handle
move.w #$3F,-(a7) read RESOUND.INF
trap #1
add.l #12,a7
lea read(PC),a1
tst.l d0
bmi problem
move.w d5,-(a7) close RESOUND.INF
move.w #$3E,-(a7)
trap #1
addq.l #4,a7
lea freq_ind(PC),a1 convert frequency index
move.b (a1),d0
sub.b #48,d0
lsl.b #1,d0
move.b d0,(a1)
move.w #0,-(a7) get sample file length
pea snd_file(PC)
move.w #$4E,-(a7)
trap #1
add.l #8,a7
lea no_dig(PC),a1
tst d0
bne problem
lea dta(PC),a6 save sample file length
move.l 26(a6),d7
add.l d7,d6 add file length to program size
lea snd_buf,a0
lea pointers(PC),a6 save buffer pointer
move.l a0,(a6)+
move.l a0,a5
add.l d7,a0 calculate buffer end pointer
move.l a0,(a6) save buffer end pointer
clr.w -(a7) open sample file
pea snd_file(PC)
move.w #$3D,-(a7)
trap #1
add.l #8,a7
lea open(PC),a1
tst.l d0
bmi problem
move.w d0,d5 save file handle
move.l a5,-(a7) pointer to sample buffer
move.l d7,-(a7) size of sample buffer
move.w d5,-(a7) file handle
move.w #$3F,-(a7) read sample file
trap #1
add.l #12,a7
lea read(PC),a1
tst.l d0
bmi problem
move.w d5,-(a7) close sample file
move.w #$3E,-(a7)
trap #1
addq.l #4,a7
lea start(PC),a0 replace etv_term vector
move.l a0,$408
pea done(PC) print message
move.w #$9,-(a7)
trap #1
addq.l #6,a7
move.l d4,-(a7) return to user mode
move.w #$20,-(a7)
trap #1
addq.l #6,a7
clr.w -(a7) keep process
move.l d6,-(a7)
move.w #$31,-(a7)
trap #1
problem move.l a1,-(a7) print error message
move.w #$9,-(a7)
trap #1
addq.l #6,a7
pea abort(PC)
move.w #$9,-(a7)
trap #1
addq.l #6,a7
move.w #1,-(a7) wait for keypress
trap #1
addq.l #2,a7
move.l d4,-(a7) return to user mode
move.w #$20,-(a7)
trap #1
addq.l #6,a7
clr.w -(a7) terminate
trap #1
* GET PARAMETERS/ENTER SUPERVISOR MODE TO ACCESS I/O REGISTERS
start movem.l d0-d7/a0-a6,-(a7) save registers
move.l #$FF8800,a0 set up sound chip registers
move.b #0,(a0)
move.b #0,2(a0)
move.b #1,(a0)
move.b #0,2(a0)
move.b #2,(a0)
move.b #0,2(a0)
move.b #3,(a0)
move.b #0,2(a0)
move.b #4,(a0)
move.b #0,2(a0)
move.b #5,(a0)
move.b #0,2(a0)
move.b #7,(a0)
move.b #$ff,2(a0)
move.b #8,(a0)
move.b #0,2(a0)
move.b #9,(a0)
move.b #0,2(a0)
move.b #10,(a0)
move.b #0,2(a0)
lea int_vector(PC),a6 get internal interrupt vector
lea snd_out(PC),a4 get pointer to sound table
lea kbd_off(PC),a0 disable keyboard
bsr ikbdws
move.w #5,-(a7) disable timer c interrupt
move.w #26,-(a7)
trap #14
addq.l #4,a7
lea pointers(PC),a1
move.l (a1)+,a3 get pointer to sound buffer
move.l (a1),d6 get end-of-buffer pointer
lea frequency(PC),a0 get timer parameters
lea freq_ind(PC),a1
clr.w d0
move.b (a1),d0
move.w 0(a0,d0.w),d5
clr.w d4
move.w d5,d4 extract timer parameters from d5
andi.w #$FF,d5 get timer control byte
lsr.w #8,d4 get timer data data
bsr xbtimer start mfp timer
bclr.b #3,$FFFA17 set automatic end-of-interrupt mode
move.w sr,-(a7) save status register
move.w #$2400,sr permit level 6 interrupts only
* MAIN PLAYBACK LOOP - TEST FOR END OF SAMPLE BUFFER
test_end cmp.l a3,d6 end of buffer?
bhi test_end
* STOP INTERRUPT GENERATION
move.w #$2700,sr disable all interrupts
bset.b #3,$FFFA17 set software end-of-interrupt mode
clr.w d5 stop mfp timer
bsr xbtimer
move.w #5,-(a7) re-enable timer c interrupt
move.w #27,-(a7)
trap #14
addq.l #4,a7
lea kbd_on(PC),a0 re-enable keyboard
bsr ikbdws
clear btst.b #0,$FFFC00 characters in keyboard buffer?
beq re_status
move.b $FFFC02,d7 if go, clear buffer
bra clear
re_status move.w (a7)+,sr retrieve status register
movem.l (a7)+,d0-d7/a0-a6 restore registers
rts
* TURN KEYBOARD OFF/ON
ikbdws move.l a0,-(a7) pointer to string
move.w #0,-(a7) 1 parameter in string
move.w #25,-(a7) write string to keyboard processor
trap #14
addq.l #8,a7
rts
* START/STOP MFP TIMER A
xbtimer move.l a6,-(a7) interrupt vector
move.w d4,-(a7) timer a data
move.w d5,-(a7) timer a control
move.w #0,-(a7) timer a select
move.w #31,-(a7) start mfp timer
trap #14
add.l #12,a7
rts
* INTERRUPT ROUTINE
int_vector clr.w d7 clear table lookup index
move.b (a3)+,d7 get byte from sample buffer
add.b #$80,d7 convert to signed value
lsl.w #3,d7 double longword offset
move.l 0(a4,d7.w),d0 load sound to psg registers
move.l #$FF8800,a2 sound chip pointer
dc.w $01CA movep.l d0,0(a2)/move data to
dc.w $00 sound chip volume registers
move.w 4(a4,d7.w),d0 movep.w d0,0(a2)
dc.w $018A
dc.w $00